<!DOCTYPE html>
<html>
   <head>
      <title>中兴西田质量异常处理单</title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0 Access-Control-Allow-Origin:*">
      <!-- 引入 Bootstrap -->
      <!--<link href="<?=base_url('html/bootstrap_v3/css/bootstrap.css')?>" rel="stylesheet">-->
      <link href="<?=base_url('html/bootstrap_v3/css/bootstrap.css')?>" rel="stylesheet">
      <link href="<?=base_url('html/bootstrap_v3/datepicker/css/bootstrap-datetimepicker.min.css')?>" rel="stylesheet">
      <!--<link href="<?=base_url('html/bootstrap_v3/css/bootstrap-glyphicons.css')?>" rel="stylesheet">-->
      <link rel="stylesheet" type="text/css" href="<?=  base_url('html/css/webuploader.css')?>">
      <link rel="stylesheet" type="text/css" href="<?=  base_url('html/css/diyUpload.css')?>">
      <link rel="stylesheet" type="text/css" href="<?=  base_url('html/css/jquery-ui.min.css')?>">
      <script src="<?=base_url('html/js/jquery-1.8.3.min.js')?>"></script>
      <script src="<?=base_url('html/bootstrap_v3/js/bootstrap.min.js')?>"></script>
      <script src="<?=base_url('html/bootstrap_v3/datepicker/js/bootstrap-datetimepicker.js')?>"></script>
      <script src="<?=base_url('html/js/jquery-ui.min.js')?>"></script>
      <script src="<?=base_url('html/bootstrap_v3/datepicker/js/locales/bootstrap-datetimepicker.zh-CN.js')?>"></script>
      <script type="text/javascript" src="<?=  base_url('html/js/webuploader.html5only.min.js')?>"></script>
      <script type="text/javascript" src="<?=  base_url('html/js/diyUpload.js')?>"></script>
      
      <!-- HTML5 Shim 和 Respond.js 用于让 IE8 支持 HTML5元素和媒体查询 -->
      <!-- 注意： 如果通过 file://  引入 Respond.js 文件，则该文件无法起效果 -->
      <!--[if lt IE 9]>
         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
         <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
      <![endif]-->
      <style type="text/css">
          .body{background-color: #f5f5f5;}
          .margin_left{margin-left: 0.3em;}
          .margin_right{margin-right: 0.5em;}
          .float-right{float: right;}
          .small{height: 20px;width: 20px;}
          .margin-bottom30{margin-bottom: 20px;}
          #image{ margin:50px auto; width:240px; min-height:80px; background:#FF9}
      </style>
   </head>
   <body>
    <?php if($type == "show"):?>
       <script type="text/javascript">
           $(document).ready(function(){
                $('#test').diyUpload({
                        url:"<?=base_url('fileupload')?>",
                        success:function( data ) {
                            $("#Thumb").val(data.result);
                                console.info( data );
                        },
                        error:function( err ) {
                                console.info( err );	
                        },
                        buttonText : '上传现场照片',
                        chunked:true,
                        // 分片大小
                        chunkSize:3072 * 1024,
                        //最大上传的文件数量, 总文件大小,单个文件大小(单位字节);
                        fileNumLimit:1,
                        fileSizeLimit:3072 * 1024,
                        fileSingleSizeLimit:3072 * 1024,
                });
                $( "#dialog" ).dialog({
                    autoOpen: false,
                    resizable: false,
                    height:140,
                    modal: true,
                    show: {
                      effect: "blind",
                      duration: 100
                    },
                    hide: {
                      effect: "explode",
                      duration: 1000
                    }
                });
                
           })
       </script>
        <div class="list-group">
               <div class="list-group-item active" style="text-align:center;font-size: 18px;font-weight: bold">中兴西田质量异常处理单</div>
               <input type="hidden" name='userid' id='userid' value='<?= isset($userid)?$userid:''?>'>
               <div class="list-group-item">
                   <span class="margin_left">制单日期</span><input type="text" readonly="readonly" name="MakeDate" value="<?=  isset($MakeDate)?$MakeDate:''?>" id="MakeDate" class="float-right">
               </div>
               <div id="dialog" title="错误信息">
                    <p id="errmsg"></p>
                </div>
               <div class="list-group-item">
                   <span class="margin_left">发生日期</span><input type="text" name="OccurDate" id="OccurDate" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">机器工号</span><input type="text" name="WorkNO" value="" id="WorkNO" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">制单人</span><input type="text" name="DocumentMaker" value="<?=  isset($DocumentMaker)?$DocumentMaker:''?>" id="DocumentMaker" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">产品名称</span><input type="text" name="ProductName" value="" id="ProductName" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">部品号</span><input type="text" name="PartsNO" value="" id="PartsNO" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">不良数量</span><input type="text" name="BadNum" value="" id="BadNum" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">责任部门</span><input type="text" name="Responsible" value="" id="Responsible" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">问题解决人</span><input type="text" name="ProblemSolver" value="" id="ProblemSolver" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">额外损失人工</span><input type="text" name="ManPower" value="" id="ManPower" class="float-right">
               </div>
               <div class="list-group-item">
                   <span class="margin_left">额外损失小时</span><input type="text" name="Hours" value="" id="Hours" class="float-right">
               </div>
               <div class="list-group-item" style="height: 100px">
                   <span class="margin_left">质量异常描述</span><textarea style="height:80px" name="QualityAbnormal" value="" id="QualityAbnormal" class="float-right"></textarea>
               </div>
               <div class="list-group-item" style="height: 100px">
                   <span class="margin_left">备注</span><textarea style="height:80px" name="Remark" value="" id="Remark" class="float-right"></textarea>
               </div>
               <div class="list-group-item">
                   <div id="test"></div>
               </div>
               <input type="hidden" name="Thumb" id="Thumb" value=''>
            
       </div>
       <div class="margin-bottom30">
            <button type="button" class="btn btn-primary btn-block submit">
                提交
            </button>
       </div>
       <script>
           $(document).ready(function(){
               $(".submit").click(function(){
                   var MakeDate       = $("#MakeDate").val();
                   var OccurDate      = $("#OccurDate").val();
                   var WorkNO         = $("#WorkNO").val();
                   var DocumentMaker  = $("#DocumentMaker").val();
                   var ProductName    = $("#ProductName").val();
                   var PartsNO        = $("#PartsNO").val();
                   var BadNum         = $("#BadNum").val();
                   var Responsible    = $("#Responsible").val();
                   var ProblemSolver  = $("#ProblemSolver").val();
                   var ManPower       = $("#ManPower").val();
                   var Hours          = $("#Hours").val();
                   var QualityAbnormal= $("#QualityAbnormal").val();
                   var Remark         = $("#Remark").val();
                   var Thumb          = $("#Thumb").val();  
                   var userid         = $("#userid").val();
                    $.ajax({
                       type:"GET",
                       dataType: "json",
                       url:"<?=  base_url()?>QualityAbnormal/add?MakeDate="+MakeDate+"&OccurDate="+OccurDate+"&WorkNO="+WorkNO+"&DocumentMaker="+DocumentMaker+"&ProductName="+ProductName+"&PartsNO="+PartsNO+"&BadNum="+BadNum+"&Responsible="+Responsible+"&ProblemSolver="+ProblemSolver+"&ManPower="+ManPower+
                               "&Hours="+Hours+"&QualityAbnormal="+QualityAbnormal+"&Remark="+Remark+"&userid="+userid+"&Thumb="+Thumb,
                       success:function(data){
                            window.location.href="<?=  base_url()?>QualityAbnormal/SubmitSuccess?orderno="+data.orderno+"&userid="+data.userid;
                       },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                                //alert(XMLHttpRequest.status);
                                //alert(XMLHttpRequest.readyState);
                                //alert(textStatus);
                                alert("您更新的信息有误，请重新确认或联系管理员！");
                        }
                   });
               });
           })
           
       </script>
       <script type="text/javascript">
            $('#OccurDate').datetimepicker({
              minView:"month",
              format:'yyyy-mm-dd',
              language: 'zh-CN',
              weekStart: 1,
              todayBtn: 1,
              autoclose: 1,
              todayHighlight: 1,
              startView: 2,
              forceParse: 0,
              showMeridian: 1
            });
        </script>
        <?php elseif($type == "success"):?>
        <div>
            <p style="color: green;margin-top: 50px;text-align: center">
               你好，质量异常单已经生成，单号是 <span style="font-weight: bold;"><?=$orderno?></span>
            </p>
            <br>
            <p style="text-align: center">
                <a href="<?=  base_url()?>QualityAbnormal/back?userid=<?=$userid?>">返回</a>
            </p>
        </div>
        <?php endif;?>
   </body>
</html>